package com.demo.house.common;

import lombok.Data;

/**
 *@description:   统一响应类
 *@author:        zhushubiao
 *@email:         617374631@qq.com
 *@date:          2020/9/14
 *@time:          16:01
 */
public class Result<T> {

    /**
     * 状态码
     */
    private Integer code;

    /**
     * 提示信息
     */
    private String msg;

    /**
     *返回的数据
     */
    private T data;

    /**
     * 构造方法
     * @param code
     * @param msg
     */
    public Result(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    /**
     * 设置数据
     * @param data
     * @return
     */
    public Result setData(T data) {
        this.data = data;
        return this;
    }

    /**
     * 设置提示信息
     * @param msg
     * @return
     */
    public Result setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    /**
     * 失败
     * @return
     */
    public static Result getFailure(){
        return new Result(400,"失败");
    }

    /**
     * 成功
     * @return
     */
    public static Result getSuccess(){
        return new Result(200,"成功");
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public T getData() {
        return data;
    }
}
